grammar Cymbol;
file : (functionDecl | varDecal)+;
varDecal : type ID ('=' expr)? ';';

functionDecl : type ID '(' formalParameters? ')' block;

formalParameters : formalParameter (',' formalParameter)*;
formalParameter : type ID;
type : 'float' | 'int' | 'void';

block : '{' stat* '}';
stat : block
     | varDecal
     | 'if' expr 'then' stat ('else' stat)?
     | 'return' expr? ';'
     | expr '=' expr ';'
     | expr ';'
     ;

expr : ID '(' exprList? ')'  # Call
     | expr '[' expr ']'     # Index
     | '-'expr               # Negate
     | '!'expr               # Not
     | expr '*' expr         # Mult
     | expr ('+'|'-') expr   # AddSub
     | expr '==' expr        # Equal
     | ID                    # var
     | INT                   # Int
     | '(' expr ')'          # Parens
     ;

exprList :  expr (',' expr)*;

ID : [a-zA-Z]+;
INT : '0' | [1-9][0-9]*;
WS : [ \t\n\r]+ -> skip;

